﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using model;
using dao;

namespace business
{
    public class SanphamTrathatBUS
    {
        SanphamTrathatDao saphamDao = new SanphamTrathatDao();
      
        public List<SanphamTrathatModel> getListsanphamByLoai(long id)
        {
            return saphamDao.getListSanphamByLoaiSanpham(id);
        }

        public List<SanphamTrathatModel> getListTop8sanphamByLoai(long id)
        {
            List<SanphamTrathatModel> listTop8 = new List<SanphamTrathatModel>();
            List<SanphamTrathatModel> listAll = new List<SanphamTrathatModel>();
            listAll = saphamDao.getListSanphamByLoaiSanpham(id);
            if (listAll.Count > 4)
            {
                for (int i = 0; i < 4; i++)
                {
                    listTop8.Add(listAll[i]);
                }
            }
            else
            {
                listTop8 = listAll;
            }
            return listTop8;
        }

        public List<SanphamTrathatModel> getListsanphamByID(long id)
        {
            return saphamDao.getListSanphamByID(id);
        }

        public string themmoiSanpham(SanphamTrathatModel bv)
        {
            return saphamDao.themmoiSanpham(bv);
        }

        public string suaSanpham(SanphamTrathatModel bv)
        {
            return saphamDao.suaSanpham(bv);
        }
    }
}
